#define  _CRT_SECURE_NO_WARNINGS
/* UVa 10189 Minesweeper */
#include<stdio.h>
int field[106][106];
int n, m;

int valid(int x, int y) {
    return (x >= 0 && y >= 0 && x < n&& y < m && field[x][y]!=-1);
}

void setmine(int x, int y) {
    int dire[] = { -1,0,1 };
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            int nex = x + dire[i], ney = y + dire[j];
            if (valid(nex, ney)) {
                field[nex][ney]++;
            }
        }
    }
}

void solve() {
     
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int ch = getchar();
            field[i][j] = ch == '*' ? -1 : 0;
        }
        getchar(); // \n
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (field[i][j] == -1) {
                setmine(i, j);
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int cur = field[i][j];
            if (cur == -1)putchar('*');
            else printf("%d", cur);
        }
        printf("\n");
    }
    return;
}

int main() {
    for (int t = 1; scanf("%d%d\n", &n, &m) && (n||m); ++t) {
        if (t != 1)printf("\n");
        printf("Field #%d:\n", t);
        solve();
    }
    return 0;
}
